<?php

//	Author: 	Aris Michail
//	Email:		std03055@di.uoa.gr
//	Purpose: 	Add an entity to a category

require_once ("../DB/connection.php");
require_once ("../DB/defines.php");
require_once ("../Frameworks/Objects/user.php");
require_once ("../Frameworks/Objects/category.php");
require_once ("../Frameworks/Objects/attribute.php");

function DB_category_addentity($owner, $category, $entity)
{

    global $conn;

    // The name of the stored procedure
    $sp_name = "usp_category_addentity";

    // The return variable
    $retval;

    // Get the values
    $username = $owner->GetUsername();
    $catname = $category->GetName();
    $entityname = $attribute->GetName();

    // REVISE TO ADD VALUES

    // Create a new statement
    $stmt = mssql_init($sp_name, $conn);

    // Bind values
    mssql_bind($stmt, "RETVAL", &$retval, SQLINT4, true, false, 1);
    mssql_bind($stmt, '@username', &$username, SQLVARCHAR, false, false, 50);
    mssql_bind($stmt, '@categoryname', &$catname, SQLVARCHAR, false, false, 50);
    mssql_bind($stmt, '@entityname', &$attrname, SQLVARCHAR, false, false, 50);

    // Execute the statement
    $status = mssql_execute($stmt);
    if (!$status)
        return DB_ERROR_CANNOTADDENTITY;
    else
        return DB_OK;
}

?>